package ejb;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceContext;
import jpa.Utente;

/**
 *
 * @author frazz
 */
@Stateless

public class GestoreLogin {

    @PersistenceContext
    private EntityManager em;
    
    
    
    public Utente entra(String username, String password) {
        Utente u = em.find(Utente.class, username);
        if(u == null){
            return null;
        }
        else{
            if(!(u.getPassword().equals(password))){
                return null;
            }
            else{
                return u;
            }
        }
    }
}
